﻿/*******************************************************************************
 
 * Author: Dealin
 
 
*********************************************************************************/
using Dealin.Application.DeviceManage;
using Dealin.Code;
using Dealin.Domain.Entity.DeviceManage;
using System.Collections.Generic;
using System.Web.Mvc;
namespace Dealin.Web.Areas.DeviceManage.Controllers
{
    public class MeterController : ControllerBase
    {
        private MeterApp app = new MeterApp();
        
        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetGridJson(string keyword)
        {
            var data = app.GetList(keyword);
            return Content(data.ToJson());
        }
        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetGridJsonByOrgId(string orgId,string typeId)
        { 
            var list = app.GetSelectItemByOrgID(orgId, typeId); 
            return Content(list.ToJson());

        }

        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetFormJson(string keyValue)
        {
            var data = app.GetForm(keyValue);
            return Content(data.ToJson());
        }
        [HttpPost]
        [HandlerAjaxOnly]
        [ValidateAntiForgeryToken]
        public ActionResult SubmitForm(MeterEntity entity,  string keyValue)
        {
            app.SubmitForm(entity, keyValue);
            return Success("操作成功。");
        }
        [HttpPost]
        [HandlerAjaxOnly]
        [HandlerAuthorize]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteForm(string keyValue)
        {
            app.DeleteForm(keyValue);
            return Success("删除成功。");
        }
    }
}
